using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;
namespace MemoryGame
{
    public class TButtonCenter
    {
        public Texture2D bitmap;
        public int width;
        public int height;
        public int width_half;
        public int height_half;
        public float scale;
        public int x,y;
        public int alpha=255;
        public TButtonCenter()
        {
        }
        public TButtonCenter(Texture2D bitmap_, int x_, int y_,float nscale)
        {
            scale = nscale;
            bitmap = bitmap_;
            width = (int)(bitmap.Width * scale);
            height = (int)(bitmap.Height * scale);
            width_half = width / 2;
            height_half = height / 2;
            x = x_ - width_half;
            y = y_ - height_half;
        }
        public void Draw(ref SpriteBatch c)
        {
            c.Draw(bitmap, new Vector2(x, y), null, new Color(255, 255, 255, alpha), 0f, new Vector2(0, 0), new Vector2(scale, scale), SpriteEffects.None, 1);    
        }
        public bool Kick_First()
        {
            if (InputState.m_currentNumPointer < 0)
                return false;
            if (InputState.arraytouchPosX[0] >= x && InputState.arraytouchPosX[0] <= x + width)
                if (InputState.arraytouchPosY[0] >= y && InputState.arraytouchPosY[0] <= y + height)
                {
                    if (InputState.arraytouchState[0] == TouchLocationState.Pressed)
                    {
                        alpha = 100;
                        return false;
                    }
                    else if (InputState.arraytouchState[0] == TouchLocationState.Moved)
                    {
                        alpha = 100;
                        return false;
                    }
                    else if (InputState.arraytouchState[0] == TouchLocationState.Released)
                    {
                        alpha = 255;
                        return true;
                    }

                }
            alpha = 255;
            return false;
        }
    }
}
